package com.gy.studyonlineapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.gy.studyonlineapp.R;
import com.gy.studyonlineapp.entity.ErrorItem;

import java.util.List;

public class ErrorItemAdapter extends ArrayAdapter<ErrorItem> {

    private int resourceId;

    public ErrorItemAdapter(@NonNull Context context, int resourceId, List<ErrorItem> list) {
        super(context, resourceId, list);
        this.resourceId = resourceId;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        ErrorItem item = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId, null);
        TextView id = view.findViewById(R.id.error_objectId);
        TextView content = view.findViewById(R.id.content);
        id.setText(item.getId());
        content.setText(item.getContent());
        return view;
    }
}